<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>

body { height: 1400px; }
body.shrink { height: 1000px; }

#anchor {
  display: block;
  position: absolute;
  width: 100px;
  height: 100px;
  background-color: #fdd;
  left: 200px;
  top: 600px;
}

</style>
<a id="anchor" name="foo"></a>
<script>

test(function(t) {
  location.hash = "#foo";
  assert_equals(scrollY, 600);
  document.body.className = "shrink";
  document.body.offsetHeight; // Force layout.
  anchor.style.top = "200px";
  assert_equals(scrollY, 200);
}, "Preserve fragment anchor if clamping occurs during load.");

</script>
